package com.orhon.smartcampus.modules.teacher.mm;


import java.util.List;

import com.orhon.smartcampus.modules.user.mm.UserMapper;
import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import com.orhon.smartcampus.modules.base.mm.DictionaryMapper;
import com.orhon.smartcampus.modules.base.mm.LangMapper;
import com.orhon.smartcampus.modules.base.mm.RegionMapper;
import com.orhon.smartcampus.modules.base.mm.SchoolMapper;
import com.orhon.smartcampus.modules.teacher.entity.TInformation;
import com.orhon.smartcampus.modules.teacher.gqlModel.GQLTeacher;

@Mapper(
        uses = {
                SchoolMapper.class,
                LangMapper.class,
                RegionMapper.class,
                DictionaryMapper.class,
                UserMapper.class
        }
)
public interface TeacherMapper {

    TeacherMapper MAPPER = Mappers.getMapper(TeacherMapper.class);
    @Mappings({
            @Mapping(source = "id" , target = "id"),
            @Mapping(source = "idcard" , target = "idcard"),
            @Mapping(source = "gender" , target = "gender", qualifiedByName = "str2dic"),
            @Mapping(source = "birthday" , target = "birthday"),
            @Mapping(source = "nativeprovince" , target = "native_province", qualifiedByName = "str2reg"),
            @Mapping(source = "nativecity" , target = "native_city", qualifiedByName = "str2reg"),
            @Mapping(source = "nativecounty" , target = "native_county", qualifiedByName = "str2reg"),
            @Mapping(source = "birthprovince" , target = "birth_province", qualifiedByName = "str2reg"),
            @Mapping(source = "birthcity" , target = "birth_city", qualifiedByName = "str2reg"),
            @Mapping(source = "birthcounty" , target = "birth_county", qualifiedByName = "str2reg"),
            @Mapping(source = "type" , target = "type", qualifiedByName = "str2dic"),
            @Mapping(source = "email" , target = "email"),
            @Mapping(source = "telnumber" , target = "telnumber"),
            @Mapping(source = "nationality" , target = "nationality", qualifiedByName = "str2dic"),
            @Mapping(source = "politicaltype" , target = "political_type", qualifiedByName = "str2dic"),
            @Mapping(source = "workstatus" , target = "work_status", qualifiedByName = "str2dic"),
            @Mapping(source = "workdate" , target = "work_date"),
            @Mapping(source = "jobtitle" , target = "job_title", qualifiedByName = "str2dic"),
            @Mapping(source = "education" , target = "education", qualifiedByName = "str2dic"),
            @Mapping(source = "degree" , target = "degree", qualifiedByName = "str2dic"),
            @Mapping(source = "mastersupervisor" , target = "master_supervisor", qualifiedByName = "str2dic"),
            @Mapping(source = "teach" , target = "teach", qualifiedByName = "str2dic"),
            @Mapping(source = "talentcategorySix" , target = "talent_category_six", qualifiedByName = "str2dic"),
            @Mapping(source = "talentcategoryNine" , target = "talent_category_nine", qualifiedByName = "str2dic"),
            @Mapping(source = "cmbprovince3" , target = "cmbprovince3", qualifiedByName = "str2reg"),
            @Mapping(source = "cmbcity3" , target = "cmbcity3", qualifiedByName = "str2reg"),
            @Mapping(source = "cmbcounty3" , target = "cmbcounty3", qualifiedByName = "str2reg"),
            @Mapping(source = "cmbprovince2" , target = "cmbprovince2", qualifiedByName = "str2reg"),
            @Mapping(source = "cmbcity2" , target = "cmbcity2", qualifiedByName = "str2reg"),
            @Mapping(source = "cmbcounty2" , target = "cmbcounty2", qualifiedByName = "str2reg"),
            @Mapping(source = "nation" , target = "nation", qualifiedByName = "str2dic"),
            @Mapping(source = "imgphotos" , target = "imgphotos"),
            @Mapping(source = "signimg" , target = "signimg"),
            @Mapping(source = "teacherName" , target = "name"),
            @Mapping(source = "introduction" , target = "introduction"),
            @Mapping(source = "createdBy" , target = "created_by"),
            @Mapping(source = "updatedBy" , target = "updated_by"),
            @Mapping(source = "createdAt" , target = "created_at"),
            @Mapping(source = "updatedAt" , target = "updated_at"),
            @Mapping(source = "deletedAt" , target = "deleted_at"),
            @Mapping(source = "userUsersByUserId" , target = "user"),
            @Mapping(ignore = true, source = "baseSchoolsBySchoolId" , target = "school"),
            @Mapping(ignore = true, source = "subjects" , target = "subjects"),
            @Mapping(ignore = true, source = "grades" , target = "grades"),
            @Mapping(ignore = true, source = "periods" , target = "periods"),
    })
    GQLTeacher toTeacher(TInformation entity);

    @InheritConfiguration(name = "toTeacher")
    List<GQLTeacher> toTeacherList(List<TInformation> entities);


}
